package com.github.zhijieqing.socket.cluster.common.listener;

import lombok.AllArgsConstructor;

@AllArgsConstructor
public class PubSubListener<V> implements MessageListener<Object>{

    private final Class<V> type;
    private final MessageListener<V> listener;

    @Override
    public void onMessage(Object msg) {
        if ( type.isInstance(msg)) {
            listener.onMessage((V) msg);
        }
    }
}
